const path = require('path')
const webpack = require('webpack')

function resolve(dir) {
    return path.join(__dirname, dir)
}
module.exports = {
    devServer: {
        // 设置主机地址
        host: '0.0.0.0',
        // 设置默认端口
        port: 8080,
        // 设置代理
        proxy: {
            '/api': {
                // 目标 API 地址
                //target: 'http://www.caipiao.com/',
                target: 'http://app.aebrowser.cn/',
                //target: 'http://hbmm.test.com',
                // 如果要代理 websockets
                ws: true,
                // 将主机标头的原点更改为目标URL
                changeOrigin: true
            }
        }
    },
    publicPath: '/',
    assetsDir: "static",
    css: {
        loaderOptions: {
            sass: {
                // @是src的别名
                data: `
                @import "@/common/sass/variable.scss";
              `
            },
            less: {
                use: ['style-loader', 'css-loader', 'less-loader'],
                modifyVars: {
                    'tabs-bottom-bar-color': 'black'
                }
            }
        }
    },
    pluginOptions: {

    },
    chainWebpack(config) {
        config.resolve.alias
            .set('components', resolve('src/components'))
            .set('common', resolve('src/common'))
            .set('@', resolve('src'))
            .set('src', resolve('src'))
            .set('vendor', resolve('src/vendor'))
        config.plugin('context')
            .use(webpack.ContextReplacementPlugin, [/moment[/\\]locale$/, /zh-cn/])
    }
}